/**
 * Created by gengrong on 16/5/7.
 */
import { SmartForm } from 'comps/common';
import { Form, Row, Col, Button } from 'antd';
import CompanyDevTeamSelection from '../../containers/selection/company-dev-team-select';
import * as React from 'react';

class RunnableGroupTransfer extends React.Component {
  doSubmit(evt) {
    evt.preventDefault();
    this.props.smartSubmit(values => {
      return this.props.onSubmit(values.team);
    });
  }

  render() {
    const { form, detail, devTeamDetail, submiting } = this.props;

    const teamProps = form.getFieldProps('team', {
      rules: [{ required: true, message: '请选择要转交的开发组' }]
    });

    return (
      <Form horizontal onSubmit={::this.doSubmit}>
        <Row>
          <Col offset='4' span='8'>
            <Form.Item labelCol={{ span: 6 }} wrapperCol={{ span: 14 }} label='当前开发组：'>
              <p>{devTeamDetail.devTeam ? devTeamDetail.devTeam.name : ''}</p>
            </Form.Item>
          </Col>
          <Col span='8'>
            <Form.Item labelCol={{ span: 6 }} wrapperCol={{ span: 14 }} label='选择开发组：'>
              <CompanyDevTeamSelection {...teamProps} companyId={detail.runnableGroup.companyId}
                style={{ width: '100%' }}
              />
            </Form.Item>
          </Col>
        </Row>
        <Row type='flex' justify='center'>
          <Col span='12'>
            <Button htmlType='submit' type='primary' loading={submiting}>提交</Button>
          </Col>
        </Row>
      </Form>
    );
  }
}

RunnableGroupTransfer = Form.create({})(SmartForm.beSmart()(RunnableGroupTransfer));

export default RunnableGroupTransfer;
